//
//  InvestService.m
//  investevent
//
//  Created by jiangshao on 16/3/10.
//  Copyright © 2016年 com.scj.investevent. All rights reserved.
//

#import "InvestService.h"

@implementation InvestService

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

+(NSInteger)getInvestCellHeight:(NSDictionary *)data{
    NSArray *events=[data objectForKey:@"events"];
    NSArray *concept=[data objectForKey:@"concept"];
    int originalheight=36;
    for (int i=0;i<events.count;i++) {
        NSArray *eventitems=events[i];
        NSArray *conceptitems=concept[i];
        UILabel *textlabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, screenviewwidth, 0)];
        NSString *event=eventitems[0];
        textlabel.text=[NSString stringWithFormat:@"股市事件:%@",event];
        textlabel.font=[UIFont systemFontOfSize:16];
        if (conceptitems.count>0) {
            NSString *conceptitem=[conceptitems[0]objectForKey:@"name"];
            textlabel.text=[NSString stringWithFormat:@"股市事件:%@\n影响板块:%@",event,conceptitem];
        }
        [textlabel resizeHeight];
        
        CGSize size = [textlabel.text boundingRectWithSize:CGSizeMake(screenviewwidth-16, MAXFLOAT)
                                              options:NSStringDrawingUsesLineFragmentOrigin
                                           attributes:@{NSFontAttributeName:textlabel.font}
                                              context:nil].size;
        
        originalheight=originalheight+size.height+16;
    }
    originalheight=originalheight+20;
    
    return originalheight;
}

@end
